Skip to content

Add a structuredClone() global - #518

Closed
dan-distributive wants to merge 2 commits into
mainfrom
feature/structured-clone
Closed

dan-distributive wants to merge 2 commits into
mainfrom
feature/structured-clone

Conversation

@dan-distributive

Copy link
Copy Markdown
Contributor

Adds structuredClone() as a global, using core-js's polyfill, the same way url.js and dom-exception.js provide URL and DOMException.

dcp-client's supervisor calls structuredClone() (origin access templates, error shapes). Without it, localExec() under PythonMonkey stops at the supervisor (dcp MR !3327).

  • builtin_modules/structured-clone.js, loaded at import next to url
  • global.d.ts declaration
  • tests/js/structured-clone.simple: arrays, Map, Date, Uint8Array, cycles, and DataCloneError for functions

Tested with pmjs on macOS arm64 against an installed 1.4.1 with the module overlaid; url.simple, test-atob-btoa.simple and set-timeout.simple still pass.

🤖 Generated with Claude Code

dcp-client's supervisor clones its origin-access templates and error shapes
with structuredClone(), which SpiderMonkey's shell globals don't provide, so
localExec() under PythonMonkey stops there. Use core-js's polyfill, as url.js
and dom-exception.js already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dan-distributive

Copy link
Copy Markdown
Contributor Author

Superseded: Tom is implementing structuredClone() natively with SpiderMonkey's structured clone, which avoids the cost of core-js's JS polyfill. An earlier native draft by Joseph Acernese (structuredClone.cc + builtin_modules/structured-clone.js) is a starting point. Separately, Paul is checking whether dcp-client's supervisor needs structuredClone() at all. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant